home *** CD-ROM | disk | FTP | other *** search
- #include "global.h"
- void main(int argc, char **argv)
- {
- int arg = 1;
- #ifdef _AMIGA
- if(atexit(&CloseSystemResources))
- exit(EXIT_FAILURE); /* Exit trap could not be set up */
-
- if(signal(SIGINT, &catch_break) == SIG_ERR)
- exit(EXIT_FAILURE); /* Interrupt handler could not be set up */
-
-
- if(LocaleBase = OpenLibrary("locale.library", 38L)) {
- if(catalog = OpenCatalog(NULL, "nuweb.catalog", OC_BuiltInLanguage,
- "english", TAG_DONE)) {
- for(i = MSG_WARNING_11B; i <= MSG_ERROR_62A2; i++)
- AppStrings[i].as_Str = GetCatalogStr(catalog, i, AppStrings[i].as_Str);
- }
- }
- #endif
-
- command_name = argv[0];
- while (arg < argc) {
- char *s = argv[arg];
- if (*s++ == '-') {
- {
- char c = *s++;
- while (c) {
- switch (c) {
- case 'c': compare_flag = FALSE;
- break;
- case 'n': number_flag = TRUE;
- break;
- case 'o': output_flag = FALSE;
- break;
- case 't': tex_flag = FALSE;
- break;
- case 'v': verbose_flag = TRUE;
- break;
- #ifdef _AMIGA
- default: fprintf(stderr, get_string(MSG_WARNING_11B), command_name);
- fprintf(stderr, get_string(MSG_USAGE_11B), command_name);
- #else
- default: fprintf(stderr, "%s: unexpected argument ignored. ",
- command_name);
- fprintf(stderr, "Usage is: %s [-cnotv] file...\n",
- command_name);
- #endif
- break;
- }
- c = *s++;
- }
- }
- arg++;
- }
- else break;
- }
- {
- if (arg >= argc) {
- #ifdef _AMIGA
- fprintf(stderr, get_string(MSG_ERROR_11C), command_name);
- fprintf(stderr, get_string(MSG_USAGE_11B), command_name);
- #else
- fprintf(stderr, "%s: expected a file name. ", command_name);
- fprintf(stderr, "Usage is: %s [-cnotv] file-name...\n", command_name);
- #endif
- exit(EXIT_FAILURE);
- }
- do {
- {
- char source_name[100];
- char tex_name[100];
- char aux_name[100];
- {
- char *p = argv[arg];
- char *q = source_name;
- char *trim = q;
- char *dot = NULL;
- char c = *p++;
- while (c) {
- *q++ = c;
- #ifdef _AMIGA
- if ((c == '/') || (c == ':')) {
- #else
- if (c == '/') {
- #endif
- trim = q;
- dot = NULL;
- }
- else if (c == '.')
- dot = q - 1;
- c = *p++;
- }
- *q = '\0';
- if (dot) {
- *dot = '\0'; /* produce HTML when the file extension is ".hw" */
- html_flag = dot[1] == 'h' && dot[2] == 'w' && dot[3] == '\0';
- sprintf(tex_name, "%s.tex", trim);
- sprintf(aux_name, "%s.aux", trim);
- *dot = '.';
- }
- else {
- sprintf(tex_name, "%s.tex", trim);
- sprintf(aux_name, "%s.aux", trim);
- *q++ = '.';
- *q++ = 'w';
- *q = '\0';
- }
- }
- {
- pass1(source_name);
- if (tex_flag) {
- if (html_flag) {
- int saved_number_flag = number_flag;
- number_flag = TRUE;
- collect_numbers(aux_name);
- write_html(source_name, tex_name);
- number_flag = saved_number_flag;
- }
- else {
- collect_numbers(aux_name);
- write_tex(source_name, tex_name);
- }
- }
- if (output_flag)
- write_files(file_names);
- arena_free();
- }
- }
- arg++;
- } while (arg < argc);
- }
-
- exit(EXIT_SUCCESS);
- }